package com.sskj.cndragon.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.cndragon.http.HttpConfig;
import com.sskj.cndragon.ui.activity.AddAddressActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;


public class AddAddressActivityPresenter extends BasePresenter<AddAddressActivity> {

    public void addOrEditAddress(String userID,
                                 String name,
                                 String mobile,
                                 String province,
                                 String city,
                                 String area,
                                 String detail,
                                 String type,
                                 String addressId) {
        httpService.addOrEditAddress(userID, name, mobile, province, city, area, detail, type, addressId)
        .tag(this)
        .execute(new JsonCallBack<HttpData>(this) {
            @Override
            public void onSuccess(Response<HttpData> response) {
                HttpData body = response.body();
                ToastUtil.showShort(body.getMsg());
                if (body.getStatus() == HttpConfig.OK) {
                    mView.addressSuccess();
                }
            }
        });
    }
}
